/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package OperacoesArquivo;

import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.PrintStream;
import java.io.Writer;
import pkginterface.Agencia;

/**
 *
 * @author jakson
 */
public class Escrita {

    public static String endAgencia = "../agencias.txt";
    public static String endCliente = "../clientes.txt";

    public void GravarAgencia(Agencia ag) {

        FileOutputStream out;
        PrintStream p;
        try {
            out = new FileOutputStream(endAgencia, true);
            p = new PrintStream(out);
            p.println(ag.getCodigo());
            p.println(ag.getCidade());
            p.println(ag.getUf());
            p.close();
        } catch (Exception e) {
            System.err.println(e);
        }
    }

    public void LimpaArquivo() {
        try {
            Writer out = new FileWriter(endAgencia);
            out.write("");
            out.flush();
            out.close();
            
        } catch (Exception e) {
            System.err.println(e);
        }
    }
    
     public void DeletarAgencia(Agencia ag) {

        FileOutputStream out;
        PrintStream p;

        try {
            out = new FileOutputStream(endAgencia,true);
            p = new PrintStream(out);
            p.println(ag.getCodigo());
            p.println(ag.getCidade());
            p.println(ag.getUf());
            p.close();
        } catch (Exception e) {
            System.err.println(e);
        }
    }
}

